const {Controller} = require("ee-core");
const Services = require('ee-core/services');
const jsonUtils = require('ee-core/utils/json');


/**
 * 系统配置
 */
class SyConfigController extends Controller {

    constructor(ctx) {
        super(ctx);
    }

    async getConfigByKey(args) {
        let value = await Services.get("sureBetSqliteDb").getDbValueByKey(args)
        return jsonUtils.strictParse(value)
    }

    async saveConfig(args) {
        const { key, value } = args;
        let data = {
            key: key,
            value: value,
            createAt: Date.now(),
            updateAt: Date.now()
        }
        return  await Services.get("sureBetSqliteDb").updateDbConfig(data)
    }

}


SyConfigController.toString = () => '[class SyConfigController]';
module.exports = SyConfigController;